bitkeeper revision 1.1440 (428a703fGt3asjVc5fTAW72ClnFOog)
authorcl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk>
Tue, 17 May 2005 22:29:19 +0000 (22:29 +0000)
committercl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk>
Tue, 17 May 2005 22:29:19 +0000 (22:29 +0000)
Many files:
  g/c _readline{,s} and use regular readline{,s} functions -- the special
  _readline{,s} functions were only needed because of Twisted.
ip.py:
  Also use readlines() instead of xreadlines().
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
tools/python/xen/sv/Daemon.py
tools/python/xen/util/blkif.py
tools/python/xen/util/ip.py
tools/python/xen/xend/Blkctl.py
tools/python/xen/xend/XendDomainInfo.py
tools/python/xen/xend/encode.py
tools/python/xen/xend/server/SrvDaemon.py
tools/python/xen/xend/sxp.py

index 5a8d18e5e4b26fbc422ece343bddffc4b838a1d2..510cfa9f04f8eaa9d993c6ce0a017ee6c6e9a60b 100644 (file)
@@ -15,8 +15,6 @@ from xen.sv.params import *
 from twisted.internet import reactor
 from twisted.web import static, server, script
 
-from xen.util.ip import _readline, _readlines
-
 class Daemon:
     """The xend daemon.
     """
@@ -59,7 +57,7 @@ class Daemon:
             return 0
         # Read the pid of the previous invocation and search active process list.
         pid = open(PID_FILE, 'r').read()
-        lines = _readlines(os.popen('ps ' + pid + ' 2>/dev/null'))
+        lines = os.popen('ps ' + pid + ' 2>/dev/null').readlines()
         for line in lines:
             if re.search('^ *' + pid + '.+xensv', line):
                 if not kill:
index 21c9202788f7de798ba2696d010fff4a00ef1c27..0caf03b5cf6a179ab22cd6139ed8b15cf47d256c 100644 (file)
@@ -4,8 +4,6 @@ import string
 
 from xen.xend.XendLogging import log
 
-from xen.util.ip import _readline, _readlines
-
 def expand_dev_name(name):
     if not name:
         return name
@@ -71,7 +69,7 @@ def blkdev_uname_to_file(uname):
 def mount_mode(name):
     mode = None
     name = expand_dev_name(name)
-    lines = _readlines(os.popen('mount 2>/dev/null'))
+    lines = os.popen('mount 2>/dev/null').readlines()
     exp = re.compile('^' + name + ' .*[\(,]r(?P<mode>[ow])[,\)]')
     for line in lines:
         pm = exp.match(line)
index 2ce0b41394e398a34106d95f9d400bf09f366ae0..9133e886f2ea6dbf0284eb3afdbfe0205ba159c9 100644 (file)
@@ -4,41 +4,11 @@ import socket
 import struct
 import errno
 
-def _readlines(fd):
-    """Version of readlines safe against EINTR.
-    """
-    import errno
-    
-    lines = []
-    while 1:
-        try:
-            line = fd.readline()
-        except IOError, ex:
-            if ex.errno == errno.EINTR:
-                continue
-            else:
-                raise
-        if line == '': break
-        lines.append(line)
-    return lines
-
-def _readline(fd):
-    """Version of readline safe against EINTR.
-    """
-    while 1:
-        try:
-            return fd.readline()
-        except IOError, ex:
-            if ex.errno == errno.EINTR:
-                continue
-            else:
-                raise
-
 ##### Networking-related functions
 
 def get_defaultroute():
     fd = os.popen('/sbin/ip route list 2>/dev/null')
-    for line in fd.xreadlines():
+    for line in fd.readlines():
         m = re.search('^default via ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+) dev ([^ ]*)',
                       line)
         if m:
@@ -57,7 +27,7 @@ def get_current_ipaddr(dev='defaultroute'):
     if not dev:
         return
     fd = os.popen( '/sbin/ifconfig ' + dev + ' 2>/dev/null' )
-    for line in fd.xreadlines():
+    for line in fd.readlines():
         m = re.search( '^\s+inet addr:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).*',
                        line )
         if m:
@@ -76,7 +46,7 @@ def get_current_ipmask(dev='defaultroute'):
     if not dev:
         return
     fd = os.popen( '/sbin/ifconfig ' + dev + ' 2>/dev/null' )
-    for line in fd.xreadlines():
+    for line in fd.readlines():
         m = re.search( '^.+Mask:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).*',
                        line )
         if m:
@@ -95,7 +65,7 @@ def get_current_ipgw(dev='defaultroute'):
     if not dev:
         return
     fd = os.popen( '/sbin/route -n' )
-    for line in fd.xreadlines():
+    for line in fd.readlines():
         m = re.search( '^\S+\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)' +
                        '\s+\S+\s+\S*G.*' + dev + '.*', line )
         if m:
index 0b46f54079da1c6d69540180d9a44174e0c296a5..44a4b4980305b181b6e0e0f7c4c5045ecd6a6168 100644 (file)
@@ -8,8 +8,6 @@ import xen.util.process
 
 from xen.xend import XendRoot
 
-from xen.util.ip import _readline, _readlines
-
 xroot = XendRoot.instance()
 
 """Where network control scripts live."""
index 334a154460d71bf1e6e94a056e301507f9ea08ec..e0aae8194442639744a40061b8ee91ea6fb1dd88 100644 (file)
@@ -14,7 +14,6 @@ import time
 
 import xen.lowlevel.xc; xc = xen.lowlevel.xc.new()
 import xen.util.ip
-from xen.util.ip import _readline, _readlines
 from xen.xend.server import channel, controller
 from xen.util.blkif import blkdev_uname_to_file
 
index 48815defa9c21fdbfa11aec1391d8ceaa59e8f2b..38c9351db739e84146adcb2ad0a471e23e605531 100644 (file)
@@ -14,8 +14,6 @@ import httplib
 import random
 import md5
 
-from xen.util.ip import _readline, _readlines
-
 # Extract from HTML4 spec.
 ## The following example illustrates "multipart/form-data"
 ## encoding. Suppose we have the following form:
@@ -124,7 +122,7 @@ def encode_multipart(d):
             out.write('"\r\n')
             out.write('Content-Type: application/octet-stream\r\n')
             out.write('\r\n')
-            for l in _readlines(v):
+            for l in v.readlines():
                out.write(l)  
         else:
             out.write('Content-Disposition: form-data; name="')
index 3709f17eddb0f15ce72c483f52301367335cf010..61a0e339496cc68bb9e053f80c537ac16776d960 100644 (file)
@@ -27,8 +27,6 @@ from xen.xend.server import SrvServer
 from xen.xend import XendRoot
 from xen.xend.XendLogging import log
 
-from xen.util.ip import _readline, _readlines
-
 import channel
 import controller
 import event
@@ -99,7 +97,7 @@ class Daemon:
         """
         running = 0
         if pid:
-            lines = _readlines(os.popen('ps %d 2>/dev/null' % pid))
+            lines = os.popen('ps %d 2>/dev/null' % pid).readlines()
             exp = '^ *%d.+%s' % (pid, name)
             for line in lines:
                 if re.search(exp, line):
index e2c0de5c5b20089e5e1ab061b8a935e6ce69a009..f1de3619d59a467f84a37d2fe8aebeeb053b72a6 100644 (file)
@@ -17,7 +17,6 @@ import types
 import errno
 import string
 from StringIO import StringIO
-from xen.util.ip import _readline, _readlines
 
 __all__ = [
     "mime_type", 
@@ -714,7 +713,7 @@ def parse(io):
     """
     pin = Parser()
     while 1:
-        buf = _readline(io)
+        buf = io.readline()
         pin.input(buf)
         if len(buf) == 0:
             break